<?php if(!defined('WDK_PATH')) exit('No direct script access allowed');
abstract class WdkManager implements arrayaccess
{
	protected $page, $listsize, $total, $filter, $where, $order, $lists, $dbo;
		
	/**
	 * 	생성자
	 */
	function __construct()
	{
		$this->page		= 1;
		$this->listsize	= 15;
		$this->total	= 0;
		$this->filter	= array();
		$this->where	= array();
		$this->order	= array();
		$this->group	= array();
		$this->lists	= array();
		$this->dbo		= null;
	}
	
	//--------------------------------------------------------------------------------------------//
	//	functions to implemet for ArrayAccess
	//--------------------------------------------------------------------------------------------//
	public final function offsetSet($offset, $value) {$this->{$offset} = $value;}
    public final function offsetExists($offset) {return isset($this->{$offset});}
    public final function offsetUnset($offset) {unset($this->{$offset});}
    public final function offsetGet($offset) {return isset($this->{$offset}) ? $this->{$offset} : null;}
	//--------------------------------------------------------------------------------------------//
	
	/**
	 *	
	 */
	public function load()
	{
		if($this->page < 1) $this->page = 1;
		$where = array_merge($this->filter, $this->where);
		$this->lists = array();
		$this->total = $this->dbo->count($where);

		$this->dbo->setLimit(($this->page-1) * $this->listsize, $this->listsize);
    	$this->dbo->setOrder($this->order);
    	$this->dbo->setGroup($this->group);
		$lists = $this->dbo->getList(array('*'), $where);
		foreach($lists as $list)
		{
			$obj = $this->newObj();
			$obj->__init($list);
			array_push($this->lists, $obj);
		}
		
	}
	
	/**
	 * 	
	 */
	protected abstract function newObj();
}
?>